//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package net.mingsoft.basic.action;

import io.swagger.annotations.Api;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import net.mingsoft.base.entity.ResultData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

@Api(
        tags = {"后端-枚举类接口"}
)
@Controller
@RequestMapping({"/${ms.manager.path}/basic/enum"})
public class EnumAction extends BaseAction {
    public EnumAction() {
    }

    @ApiIgnore
    @GetMapping({"/list"})
    @ResponseBody
    public ResultData list(String allClassPath) {
        ArrayList list = new ArrayList();

        try {
            Class _class = Class.forName(allClassPath);
            Object[] enumConstants = _class.getEnumConstants();
            Arrays.stream(enumConstants).forEach((e) -> {
                HashMap<String, String> map = new HashMap();
                map.put("value", e.toString().toLowerCase());

                try {
                    Method label = e.getClass().getMethod("getLabel");
                    map.put("label", label.invoke(e).toString());
                } catch (NoSuchMethodException var4) {
                    var4.printStackTrace();
                } catch (IllegalAccessException var5) {
                    var5.printStackTrace();
                } catch (InvocationTargetException var6) {
                    var6.printStackTrace();
                }

                list.add(map);
            });
        } catch (ClassNotFoundException var5) {
            var5.printStackTrace();
        }

        return ResultData.build().success(list);
    }
}
